<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <template id="my-app">
    <component-a></component-a>
    <component-a></component-a>
    <component-a></component-a>
  </template>


  <template id="component-a">
    <h2>{{title}}</h2>
    <p>{{desc}}</p>
    <button @click="btnClick">按钮</button>
  </template>


  <script src="../js/vue.js"></script>
  <script>
    const App = {
      template: "#my-app",
      data() {
        return {
          message: "Hello World",
        }
      }
    };
    const app = Vue.createApp(App);

    app.component("component-a", {
      template: "#component-a",
      data() {
        return {
          title: "我是标题",
          desc: "我是是内容，哈哈哈"
        }
      },
      methods: {
        btnClick() {
          console.log("按钮发生点击");
        }
      }
    })
    app.mount("#app");
  </script>
</body>

</html>